
export const getComment=(data)=>{
    return {
        type:"GETCOM",
        data
    }
}


export function lookCmt(params){
    console.log(params)
    return dispatch=>{
        var url='http://localhost:3000/comment/getcate';
        return fetch(url,{
            method:'post',
            headers:{
                'Content-Type':'application/json'
            },
            body:JSON.stringify(params)
        })
        .then(res=>{
            return res.json()
        })
        .then((data)=>{
            console.log(data)
            dispatch(getComment(data));
        })
    }
}

export const getNews=(data)=>{
    return {
        type:"GETNEWS",
        data
    }
}

export function findNews(id){
    return dispatch=>{
        var url='http://localhost:3000/news/data/'+id;
        return fetch(url)
        .then(res=>{
            return res.json()
        })
        .then((data)=>{
            console.log(data)
            dispatch(getNews(data));
        })
    }
}

